//https://leetcode.cn/problems/minimum-window-substring/description/
class Solution {
    public String minWindow(String s, String t) {
        int left = 0;
        int right = 0;
        int minL = s.length() + 1;
        String str = null;
        int[] hash1 = new int[52 + 6];
        int[] hash2 = new int[52 + 6];
        int count = 0;
        for (int i = 0; i < t.length(); i++) {
            hash1[t.charAt(i) - 'A']++;
        }
        //t中有多少 种 字符
        int kindHash1 = 0;
        for (int i = 0; i < hash1.length; i++) {
            if (hash1[i] != 0) {
                kindHash1++;
            }
        }
        while (right < s.length()) {
            if (++hash2[s.charAt(right) - 'A'] == hash1[s.charAt(right) - 'A']) {
                count++;
            }
            while (count == kindHash1) {
                if (minL > right-left+1) {
                    minL = right-left+1;
                    str = s.substring(left,right+1);
                }
                if (hash2[s.charAt(left) - 'A'] == hash1[s.charAt(left) - 'A']) {
                    count--;
                }
                hash2[s.charAt(left++) - 'A']--;
            }
            right++;
        }
        return minL == s.length() + 1 ? "" : str;
    }
}